import type * as Auth from "./type"
import { request } from "@/http/axios"

/** 登录并返回 Token */
export function loginApi(data: Auth.LoginRequestData) {
  return request<Auth.LoginResponseData>({
    url: "/auth/login",
    method: "post",
    data
  })
}

/** 退出登录 */
export function logoutApi() {
  return request<ApiResponseData<null>>({
    url: "/auth/logout",
    method: "post"
  })
}

// 每次路由跳转实时获取当前角色列表
export function getCurrentUserRolesApi() {
  return request<Auth.RolesResponseData>({
    url: "/auth/current-user/roles",
    method: "get"
  })
}
